function [score,z,match_indexes1,match_indexes2,index,G,V,E]=EigenVectorMatch(cluster1,cluster2,sigma,threshold)

disp("开始计算V");
[G,V,E,index]=CalculateV(cluster1,cluster2,sigma);
disp("V计算完毕");
disp("开始计算Z");
v1= gather(V{1});
v2=gather(V{2});
% v1=V{1}.*E{1};
% v2=V{2}.*E{2};
%计算V的中心聚簇点W
wd = CalculateW(v1,cluster1);
wm = CalculateW(v2,cluster2);
centroidG1=CalculateGv2(wd,sigma);
centroidG2=CalculateGv2(wm,sigma);
%再次进行特征值分解
disp("对centroidG1进行特征值分解");
centroidG1=gpuArray(centroidG1);
[u1,d1]=eig(centroidG1);
[e1,index] = sort(diag(d1),'descend');
d1 = diag(e1);
u1 = u1(:,index);
% v1 = v1(:,index).*e1';
disp("对centroidG1特征值分解完毕");
% v1=fliplr(v1)
% e1=flip(diag(d1));
% d1=diag(e1);
centroidG2=gpuArray(centroidG2);
disp("对centroidG2进行特征值分解");
[u2,d2]=eig(centroidG2);
[e2,index] = sort(diag(d2),'descend');
d2 = diag(e2);
u2 = u2(:,index);
% v2 = v2(:,index).*e2';
disp("对centroidG2特征值分解完毕");
%EM算法
num=size(wm,2);
alpha=1/num; %初始权重alpha






% z = CalculateZ(v1,v2);
% disp("Z计算完毕");
% [len1,len2] = size(z);
% disp("开始根据Z查找匹配点");
match_count=0;
match_flag=zeros(len1,len2);
match_indexes1={};
match_indexes2={};
for i=1:len1
     [min_val,min_index]=min(z(i,:));
    for j=1:len2
        if(z(i,j)==min_val)
            [min_val2,min_index2]=min(z(:,j));
            if(min_val2==z(i,j)&&z(i,j)<threshold&&match_flag(i,j)==0&&ismember(1,match_flag(:,j))==0)
                 match_count=match_count+1;
                match_indexes1{match_count}=i;
                match_indexes2{match_count}=min_index;
                match_flag(i,j)=1;
            end
        end      
%         match_flag(min_index,i)=1;
    end
end          
score = match_count/len1;
disp(["图样1和图样2","之间的匹配特征数为",num2str(match_count),"匹配率为",num2str(score)]);